/**
 */
package autoSAR.impl;

import autoSAR.AutoSARPackage;
import autoSAR.ClientServicePPort;
import autoSAR.ClientServiceRPort;
import autoSAR.Entity;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Client Service RPort</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link autoSAR.impl.ClientServiceRPortImpl#getDataTo <em>Data To</em>}</li>
 *   <li>{@link autoSAR.impl.ClientServiceRPortImpl#getReciveFrom <em>Recive From</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ClientServiceRPortImpl extends ClientServicePortImpl implements ClientServiceRPort {
	/**
	 * The cached value of the '{@link #getDataTo() <em>Data To</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataTo()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> dataTo;

	/**
	 * The cached value of the '{@link #getReciveFrom() <em>Recive From</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReciveFrom()
	 * @generated
	 * @ordered
	 */
	protected ClientServicePPort reciveFrom;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClientServiceRPortImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AutoSARPackage.Literals.CLIENT_SERVICE_RPORT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getDataTo() {
		if (dataTo == null) {
			dataTo = new EObjectResolvingEList<Entity>(Entity.class, this,
					AutoSARPackage.CLIENT_SERVICE_RPORT__DATA_TO);
		}
		return dataTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClientServicePPort getReciveFrom() {
		if (reciveFrom != null && reciveFrom.eIsProxy()) {
			InternalEObject oldReciveFrom = (InternalEObject) reciveFrom;
			reciveFrom = (ClientServicePPort) eResolveProxy(oldReciveFrom);
			if (reciveFrom != oldReciveFrom) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE,
							AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM, oldReciveFrom, reciveFrom));
			}
		}
		return reciveFrom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClientServicePPort basicGetReciveFrom() {
		return reciveFrom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetReciveFrom(ClientServicePPort newReciveFrom, NotificationChain msgs) {
		ClientServicePPort oldReciveFrom = reciveFrom;
		reciveFrom = newReciveFrom;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
					AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM, oldReciveFrom, newReciveFrom);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReciveFrom(ClientServicePPort newReciveFrom) {
		if (newReciveFrom != reciveFrom) {
			NotificationChain msgs = null;
			if (reciveFrom != null)
				msgs = ((InternalEObject) reciveFrom).eInverseRemove(this, AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO,
						ClientServicePPort.class, msgs);
			if (newReciveFrom != null)
				msgs = ((InternalEObject) newReciveFrom).eInverseAdd(this, AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO,
						ClientServicePPort.class, msgs);
			msgs = basicSetReciveFrom(newReciveFrom, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM,
					newReciveFrom, newReciveFrom));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			if (reciveFrom != null)
				msgs = ((InternalEObject) reciveFrom).eInverseRemove(this, AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO,
						ClientServicePPort.class, msgs);
			return basicSetReciveFrom((ClientServicePPort) otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			return basicSetReciveFrom(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__DATA_TO:
			return getDataTo();
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			if (resolve)
				return getReciveFrom();
			return basicGetReciveFrom();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__DATA_TO:
			getDataTo().clear();
			getDataTo().addAll((Collection<? extends Entity>) newValue);
			return;
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			setReciveFrom((ClientServicePPort) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__DATA_TO:
			getDataTo().clear();
			return;
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			setReciveFrom((ClientServicePPort) null);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_RPORT__DATA_TO:
			return dataTo != null && !dataTo.isEmpty();
		case AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM:
			return reciveFrom != null;
		}
		return super.eIsSet(featureID);
	}

} //ClientServiceRPortImpl
